package facade;

import model.Address;
import model.Contact;
import model.Customer;
import model.Employee;
import model.EnterprisePersonRelation;
import model.Person;
import model.SubjectAttribute;
import db.ImbiConnection;

public class PersonFacade {
	public static void deletePerson(Person p){
		for(Address a: p.getAddressList()){
			ImbiConnection.getAddressDAO().delete(a);
		}
		for(SubjectAttribute a: p.getAttributes()){
			ImbiConnection.getSubjectAttributeDAO().delete(a);
		}
		for(Employee e: p.getEmployee()){
			ImbiConnection.getEmployeeDAO().delete(e);
		}
		for(Contact c: p.getContactList()){
			ImbiConnection.getContactDAO().delete(c);
		}
		for(Customer c: p.getCustomer()){
			ImbiConnection.getCustomerDAO().delete(c);
		}
		for(EnterprisePersonRelation e: p.getRelations()){
			ImbiConnection.getEnterprisePersonRelationDAO().delete(e);
		}
		ImbiConnection.getPersonDAO().delete(p);
	}
}
